﻿using System.Collections.Generic;
using NUnit.Framework;

namespace Birkelund.QueryStrings.Test
{
    internal static class ChecksumCalculatorTestHelper
    {
        public static IEnumerable<TokenKeyValue> CreateTokens(string value1, string value2)
        {
            return new []
            {
                new TokenKeyValue("a", value1),
                new TokenKeyValue("b", value2),
            };
        }

        public static void DoAssertion(IChecksumCalculator calculator, IEnumerable<TokenKeyValue> tokensBefore, IEnumerable<TokenKeyValue> tokensAfter, bool mustBeEqual)
        {
            string checksumBefore = calculator.CalculateCheckSum(tokensBefore);
            string checksumAfter = calculator.CalculateCheckSum(tokensAfter);

            if (mustBeEqual)
            {
                Assert.AreEqual(checksumBefore, checksumAfter);
            }
            else
            {
                Assert.AreNotEqual(checksumBefore, checksumAfter);
            }
        }
    }
}
